package com.augurit.wf.jbpmex.cmd;

import java.util.Date;

import org.jbpm.api.cmd.Environment;
import org.jbpm.pvm.internal.cal.Duration;
import org.jbpm.pvm.internal.cmd.AbstractCommand;

public class DurationCommon extends AbstractCommand<Date> {

	private static final long serialVersionUID = 1L;
	
	private Date startDate;//startDate 开始时间
	private String durationExpression;//结束时间的表达式，例如是"6 business days"
	
	public DurationCommon(Date startDate,String durationExpression) {
		this.startDate = startDate;
		this.durationExpression = durationExpression;
	}
	
	public Date execute(Environment environment) throws Exception {
		//计算开始日期经过几个工作日后的日期
		Date endDate = Duration.calculateDueDate(startDate, durationExpression);
		return endDate;
	}

}
